package com.tuanzi.loan.web.bean.statistics.newonekey;

import com.tuanzi.loan.business.service.statistics.NewOneKeyStatService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.statistics.newonekey.NewOneKeyStatRequest;
import com.tuanzi.loan.vo.response.statistics.newonekey.NewOneKeyStatTotalResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.statistics.NewOneKeyTotalStatLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.Date;

/**
 * @author caiwanlin
 * @create 2018-06-26 14:56
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class NewOneKeyTotalStatBean extends JSFListingBean<NewOneKeyStatRequest, NewOneKeyStatTotalResponse> {
    @Autowired
    private NewOneKeyStatService newOneKeyStatService;

    @PostConstruct
    public void init() throws Exception {
        initLazyDataModel();
    }

    private void initLazyDataModel() throws Exception {
        $ = new NewOneKeyStatRequest();
        Date date = new Date();
        $.setStartTime(date);
        $.setEndTime(date);
        lazyDataModel = new NewOneKeyTotalStatLazyDataModel($);
    }

    public void onReset() throws Exception {
        initLazyDataModel();
        /*NewOneKeyStatRequest request = new NewOneKeyStatRequest();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        request.setStartTime(format.parse("2018-06-25"));
        request.setEndTime(format.parse("2018-06-29"));
        PageSearcher<NewOneKeyStatRequest> pageSearcher = new PageSearcher<>(request, null);
        newOneKeyStatService.totalList(pageSearcher);*/
    }
}
